package com.mlan.userap.model;

import com.flyjingfish.openimagelib.beans.OpenImageUrl;
import com.flyjingfish.openimagelib.enums.MediaType;

import java.io.Serializable;

public class MsgEntity  implements Serializable,Comparable<MsgEntity>, OpenImageUrl {
    String msgId;
    /**
     * 发送id
     */
    long uidFrom;

    /**
     * 消息组Id
     */
    String groupId;
    /**
     * 消息类型  1:文本 2:图片  3:语音 4:视屏 5:文件 6:表情 7:音乐
     */
    int msgType;
    /**
     * 消息内容 1 文本  6 有用  其它的 用后面的fileInfo
     */
    String msgContent;
    /**
     * 附件信息  2 3 4 5 7 有用
     */
    MsgFileInfo fileInfo;
    /**
     * 消息时间
     */
    long msgTicks;
    /**
     * 发送人昵称
     */
    String nickFrom;
    /**
     * 发送人头像
     */
    String headFrom;

    /**
     * 本地路径
     */
    String msgAttLocal;

    public long getUidFrom() {
        return uidFrom;
    }

    public void setUidFrom(long uidFrom) {
        this.uidFrom = uidFrom;
    }



    public String getGroupId() {
        return groupId;
    }

    public void setGroupId(String groupId) {
        this.groupId = groupId;
    }

    public int getMsgType() {
        return msgType;
    }

    public void setMsgType(int msgType) {
        this.msgType = msgType;
    }

    public String getMsgContent() {
        return msgContent;
    }

    public void setMsgContent(String msgContent) {
        this.msgContent = msgContent;
    }

    public MsgFileInfo getFileInfo() {
        return fileInfo;
    }

    public void setFileInfo(MsgFileInfo fileInfo) {
        this.fileInfo = fileInfo;
    }


    public String getMsgId() {
        return msgId;
    }

    public void setMsgId(String msgId) {
        this.msgId = msgId;
    }

    public long getMsgTicks() {
        return msgTicks;
    }

    public void setMsgTicks(long msgTicks) {
        this.msgTicks = msgTicks;
    }

    public String getMsgAttLocal() {
        return msgAttLocal;
    }

    public void setMsgAttLocal(String msgAttLocal) {
        this.msgAttLocal = msgAttLocal;
    }

    public String getNickFrom() {
        return nickFrom;
    }

    public void setNickFrom(String nickFrom) {
        this.nickFrom = nickFrom;
    }

    public String getHeadFrom() {
        return headFrom;
    }

    public void setHeadFrom(String headFrom) {
        this.headFrom = headFrom;
    }

    @Override
    public int compareTo(MsgEntity other) {
        return Long.compare(this.msgTicks,other.msgTicks);
    }

    @Override
    public String getImageUrl() {
        return fileInfo.getResurl();
    }

    @Override
    public String getVideoUrl() {
        return fileInfo.getResurl();
    }

    @Override
    public String getCoverImageUrl() {
        return fileInfo.getResurl();
    }

    @Override
    public MediaType getType() {
        if (getMsgType()==2){
            return MediaType.IMAGE;
        }else if (getMsgType()==4){
            return MediaType.VIDEO;
        }
        return null;
    }
}
